﻿using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Services;
using System.Web.Services.Protocols;
using System.Xml.Linq;
using Emlyn.AudioToVideo.JobProcessorLib.core;

namespace Emlyn.AudioToVideo.JobManagerService
{
    /// <summary>
    /// JobProcessor service
    /// </summary>
    [WebService(Namespace = "http://emlynoregan.com/")]
    [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
    [ToolboxItem(false)]
    // To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line. 
    [System.Web.Script.Services.ScriptService]
    public class JobProcessor : System.Web.Services.WebService
    {
        [WebMethod]
        // aJobID must not exist, aJobType must make sense, aJobDetails must be for aJobType. State of new job is Created.
        public int CreateJob(string aJobID, string aJobType, string aJobDetails, string aCallback, out string aErrorMessage)
        {
            return JobProcessorImpl.CreateJob(aJobID, aJobType, aJobDetails, out aErrorMessage);
        }

        [WebMethod]
        public int StartJob(string aJobID, out string aErrorMessage)
        {
            return JobProcessorImpl.StartJob(aJobID, out aErrorMessage);
        }

        [WebMethod]
        public int GetJobStatusAndProgress(string aJobID, out int aJobStatus, out string aJobErrorMessage, out int aProgress, out string aErrorMessage)
        {
            return JobProcessorImpl.GetJobStatusAndProgress(aJobID, out aJobStatus, out aJobErrorMessage, out aProgress, out aErrorMessage);
        }

        [WebMethod]
        public int CancelJob(string aJobID, out string aErrorMessage)
        {
            return JobProcessorImpl.CancelJob(aJobID, out aErrorMessage);
        }

        [WebMethod]
        public int DeleteJob(string aJobID, out string aErrorMessage)
        {
            return JobProcessorImpl.DeleteJob(aJobID, out aErrorMessage);
        }
    }
}
